#include <iostream>
#include <string>
#include <fstream>
#include "LapTop.h"
#include <stdlib.h> 
using namespace std;

string DocFile(string strTenFile)
{
	LapTop *lap = new LapTop[100];
	DateBuy ngayMua;
	SinhVien *sv = new SinhVien[100];
	string line("");
	char * ptrCut;
	char * maMayTinh;
	char * tenMayTinh;
	int ngay;
	int thang;
	int nam;
	char * hoTen;
	double dbDiem;
	int count = 0;
	int soDong = 0;
	ifstream myfile;
	myfile.open(strTenFile);

	while (!myfile.eof())
	{
		getline(myfile,line);
		ptrCut = strtok ((char*)line.c_str(),"\t");
		while (ptrCut != NULL)
		{
			count++;
			if (count == 1)
			{
				maMayTinh = ptrCut;
				lap[soDong].setMaMayLapTop(maMayTinh);
			}
			if (count == 2)
			{
				tenMayTinh = ptrCut;
				lap[soDong].setTenMayLapTop(tenMayTinh);
			}
			if (count == 3)
			{
				ngay = atoi(ptrCut);
				ngayMua.setNgay(ngay);
			}
			if (count == 4)
			{
				thang = atoi(ptrCut);
				ngayMua.setThang(thang);
			}
			if (count == 5)
			{
				nam = atoi(ptrCut);
				ngayMua.setName(nam);
			}
			if (count == 6)
			{
				hoTen = ptrCut;
				sv[soDong].setHoTen(hoTen);
			}
			if (count == 7)
			{
				dbDiem = atoi(ptrCut);
				sv[soDong].setDiem(dbDiem);
			}
			
			ptrCut = strtok (NULL, "\t/");
			if (ptrCut == NULL)
			{
				count = 0;
			}
		}
		soDong++;
		//lap.InLapTop();
		//ngayMua.InDateBuy();
		//sv.InSinhVien();
		//cout<<"\n\n";
	}

	for (int a = 0; a < soDong; a++)
	{
		sv[a].InSinhVien();
		lap[a].InLapTop();
	}
	myfile.close();
	return line;
}




int main()
{


	DocFile("DanhSach.txt");
	system("pause");
}